<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <div class="home">
            <h2 style="text-align: left;">Exam requests</h2>
            <div style="color:red; text-align: center"><i>${message}</i></div><br>
            <%int i = 1;%>
            <table class="gradesTableId" border="4">
                <tr class="gradesHeader">
                    <td>
                        No.
                    </td>
                    <td>
                        Subject matter
                    </td>
                    <td>
                        Proffessor
                    </td>
                    <td>
                        Class
                    </td>
                    <td>
                        Date
                    </td>
                    <td>
                        Hour
                    </td>
                    <td>
                        Location
                    </td>
                    <td>
                        Status
                    </td>
                    <td>
                        Action
                    </td>
                </tr>
                <s:iterator value="#session.requestedExams" status="status" var="myobj">
                    <s:if test="#myobj.stat==2">
                        <s:set var="style" value="%{'color: white; background-color: red;'}"/>
                        <s:set var="examStatus" value="%{'rejected'}"/>
                    </s:if>
                    <s:elseif test="#myobj.stat!=1">
                        <s:set var="style" value="%{'background-color: yellow;'}"/>
                        <s:set var="examStatus" value="%{'in pending'}"/>
                    </s:elseif>
                    <s:else>
                        <s:set var="style" value="%{'background-color: white; color: black;'}"/>
                        <s:set var="examStatus" value="%{'approved'}"/>
                    </s:else>
                    <tr style="<s:property value='style' />">
                        <td>
                            <%=i++%>
                        </td>
                        <td>
                            <s:property value="subjectMatter.name" />
                        </td>
                        <td>
                            <s:property value="proffessor.name" />
                        </td>
                        <td>
                            <s:property value="cls.number" />
                        </td>
                        <td>
                            <s:property value="date" />
                        </td>
                        <td>
                            <s:property value="hour" />
                        </td>
                        <td>
                            <s:property value="location" />
                        </td>
                        <td>
                            <s:property value="examStatus" />
                        </td>
                        <td style="background-color: white; width: 110px;">
                            <dl class="appRej">
                                <dt>
                                    <s:url action="ApproveExam" var="approve">
                                        <s:param name="examId" value="id"/>
                                    </s:url>
                                
                                    <a href="<s:property value='#approve'/>" style="text-align: center;">
                                        approve
                                    </a>
                                <dt>   
                            </dl>
                            <dl class="appRej">
                                <dt>
                                    <s:url action="Button!reject" var="reject">
                                        <s:param name="examId" value="id"/>
                                    </s:url>
                                
                                    <a href="<s:property value='#reject' />" style="text-align: center;">
                                        reject
                                    </a>
                                <dt>
                            </dl>
                        </td>
                    </tr>
                </s:iterator>
            </table>
        </div>
    </body>
</html>
